<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>清除浮动</title>
  <style>
    .clearfix {
      *zoom: 1;
    }

    .clearfix:after {
      content: ".";
      display: block;
      height: 0;
      visibility: hidden;
      clear: both;
    }

    .float {
      float: left;
      width: 200px;
      height: 200px;
    }
  </style>
</head>

<body>
  <div class="clearfix">
    <div class="float" style="background-color: pink;"></div>
    <div class="float" style="background-color: silver;"></div>
  </div>
  <div style="width:500px;height: 300px;background-color: orange;">

  </div>

</body>

</html>